#include <cmath>

#include "glVector.h"
#include "math_funcs.h"



// Constructor
glVector::glVector() {
	i = j = k = 0.0f;
}

// Destructor
glVector::~glVector() {
}

void glVector::operator *=(GLfloat scalar) {
	i *= scalar;
	j *= scalar;
	k *= scalar;
}

void glVector::SetValues(const float x, const float y, const float z) {
	this->i = x;
	this->j = y;
	this->k = z;

	return;
}


double glVector::Normalize(void) {
	double len = Length();

	if (FLOAT_EQ(0.0f,len))	// if length is zero
	{
		i =	0.0f;
		j =	0.0f;
		k =	0.0f;
	}
	else		// normalize
	{
		i = (float)(i / len);
		j = (float)(j / len);
		k = (float)(k / len);

		Zero_Clamp();
	}

	return(len);
}	// end double Normalize()

double glVector::Length(void) const {
	return( sqrt(i*i + j*j + k*k)  );
}

void glVector::Zero_Clamp(void)
{
	i	= ZERO_CLAMP(i);
	j	= ZERO_CLAMP(j);
	k	= ZERO_CLAMP(k);

}	// end void Zero_Clamp()

#include <iostream>
void glVector::Print()
{
	std::cout << "Vector is " << i << " " << j << " " << k << std::endl;
}

